/**
 * eSql.cs
 * 
 * AUTHOR:
 * Zlatko Michailov (http://blogs.msdn.com/esql)
 * 
 * PURPOSE:
 * Language definition of eSQL.
 * 
 * COPYRIGHT:
 * (c) Microsoft Corp., 2006-2007
 */



using System;
using System.Text.RegularExpressions;



namespace Microsoft.Samples.Data.eSqlBlast
{
    public class eSql : ILanguage
    {
        public string[] GrammarDefinitions 
        {
            get
			{
                return new string[]
                {
				    @"(?<Script>\s*(\K<Comment>|\K<Statement>)*)",
				    @"(?<Statement>(\K<Literal>|\K<StatementHead>(\K<StatementChunk>)*)\s*)",
				    @"(?<StatementChunk>(\K<Comment>|\K<Identifier>|\K<Literal>|\K<StatementText>))",
				    @"(?<StatementHead>(\K<StatementHeadChar>)+)",
				    @"(?<StatementHeadChar>[^\s\[\]'"";/-]|/[^\*]|-[^-])",
				    @"(?<StatementText>(\K<StatementChar>)*)",
				    @"(?<StatementChar>[^\[\]'"";/-]|/[^\*]|-[^-])",
				    @"(?<Comment>\K<BlockComment>|\K<LineComment>)",
				    @"(?<BlockComment>/\*\K<BlockCommentChar>*\*/)",
				    @"(?<BlockCommentChar>[^\*]|\*[^/])",
				    @"(?<LineComment>--.*)",
				    @"(?<Identifier>\[\K<IdentifierChar>*\])",
				    @"(?<IdentifierChar>\[{2}|\]{2}|[^\]])",
				    @"(?<Literal>\K<SingleQuoteLiteral>|\K<DoubleQuoteLiteral>)",
				    @"(?<SingleQuoteLiteral>'\K<SingleQuoteLiteralChar>*')",
				    @"(?<SingleQuoteLiteralChar>'{2}|[^'])",
				    @"(?<DoubleQuoteLiteral>""\K<DoubleQuoteLiteralChar>*"")",
				    @"(?<DoubleQuoteLiteralChar>""{2}|[^""])",
                };
			}
        }


        public string StatementTerminator
        {
            get
            {
                return @";";
            }
        }


        public string DeclarationKeywords
        {
            get
            {
                return @"(using)";
            }
        }


        public RegexOptions RegexOptions
        {
            get
            {
                return RegexOptions.IgnoreCase;
            }
        }
    }


    public class eSqlIntellisense : ILanguage
    {
        public string[] GrammarDefinitions
        {
            get
            {
                return new string[]
                {
				    @"(?<Script>(\K<Keyword>|\K<Identifier>|\K<Literal>|\K<Comment>)*)",
				    @"(?<Keyword>\w+)",
				    @"(?<Comment>\K<BlockComment>|\K<LineComment>)",
				    @"(?<BlockComment>/\*\K<BlockCommentChar>*\*/)",
				    @"(?<BlockCommentChar>[^\*]|\*[^/])",
				    @"(?<LineComment>--.*)",
				    @"(?<Identifier>\[\K<IdentifierChar>*\])",
				    @"(?<IdentifierChar>\[{2}|\]{2}|[^\]])",
				    @"(?<Literal>\K<SingleQuoteLiteral>|\K<DoubleQuoteLiteral>)",
				    @"(?<SingleQuoteLiteral>'\K<SingleQuoteLiteralChar>*')",
				    @"(?<SingleQuoteLiteralChar>'{2}|[^'])",
				    @"(?<DoubleQuoteLiteral>""\K<DoubleQuoteLiteralChar>*"")",
				    @"(?<DoubleQuoteLiteralChar>""{2}|[^""])",
                };
            }
        }


        public string StatementTerminator
        {
            get
            {
                return @";";
            }
        }


        public string DeclarationKeywords
        {
            get
            {
                return @"(using)";
            }
        }


        public RegexOptions RegexOptions
        {
            get
            {
                return RegexOptions.IgnoreCase;
            }
        }
    }
}
